package com.lile.stringBuffer;

public class StringSymmetry {

	public static void main(String[] args) {
		String s = "aabbaa";

		System.out.println(isSymmetryString1(s));
		System.out.println(isSymmetryString2(s));
		System.out.println(isSymmetryString3(s));
	}

	public static boolean isSymmetryString1(String s) {
		char[] chs = s.toCharArray();
		for (int start = 0, end = chs.length - 1; start <= end; start++, end--) {
			if (chs[start] != chs[end]) {
				return false;
			}
		}
		return true;
	}

	public static boolean isSymmetryString2(String s) {
		boolean flag = true;
		char[] chs = s.toCharArray();
		for (int start = 0, end = chs.length - 1; start <= end; start++, end--) {
			if (chs[start] != chs[end]) {
				flag = false;
				break;
			}
		}
		return flag;
	}

	public static boolean isSymmetryString3(String s) {

		// return new String(new StringBuffer(s).reverse()).equals(s);

		StringBuffer sb = new StringBuffer(s);
		sb.reverse();
		String ss = new String(sb);
		return ss.equals(s);
	}
}
